package com.ucomm.talent.common;

import android.content.Context;
import android.util.DisplayMetrics;

/**
 * 一般工具类
 * Created with IntelliJ IDEA.
 * User: Vita Hao
 * Date: 13-5-22
 * Time: 上午9:46
 * To change this template use File | Settings | File Templates.
 */
public class CommonUtils {
    private static int screenWidth;
    private static int screenHeight;
    private static int density;

    public static int getScreenWidth(Context context) {
        if (screenWidth != 0) {
            return screenWidth;
        }
        DisplayMetrics dm = new DisplayMetrics();
        dm = context.getResources().getDisplayMetrics();
        screenWidth = dm.widthPixels;
        return screenWidth;

    }

    public static int getScreenHeight(Context context) {
        if (screenHeight != 0) {
            return screenHeight;
        }
        DisplayMetrics dm = new DisplayMetrics();
        dm = context.getResources().getDisplayMetrics();
        screenHeight = dm.heightPixels;
        return screenHeight;
    }

    public static int getDensity(Context context) {
        if (density != 0) {
            return density;
        }
        DisplayMetrics dm = new DisplayMetrics();
        dm = context.getResources().getDisplayMetrics();
        density = dm.densityDpi;
        return density;
    }

}
